Date.prototype.format = function (format) {
    var args = {
        "M+":this.getMonth() + 1,
        "d+":this.getDate(),
        "H+":this.getHours(),
        "m+":this.getMinutes(),
        "s+":this.getSeconds(),
    };
    /*一个或多个y*/
    if(/(y+)/.test(format))
        /*RegExp.$1取到y+匹配到的内容*/
        format = format.replace(RegExp.$1,(this.getFullYear() + "").substring(4 - RegExp.$1.length));
    for (var i in args){
        var n = args[i];
        if(new RegExp("("+i+")").test(format))
            format = format.replace(RegExp.$1,RegExp.$1.length == 1 ? n : ("00" + n).substr((""+n).length));
    }
    return format;
};